<?php
/**
 * Created by PhpStorm.
 * User: C。
 * Date: 2019/8/13
 * Time: 9:04
 */
namespace app\home\controller;

use app\common\model\Version as VersionModel;

/**
 * 版本控制器
 * Class Version
 * @package app\home\controller
 */
class Version extends Base
{
    /**
     * [getversion  获取版本]
     * @param system 1安卓 2ios
     * @return json
     * @author [C。]
     */
    public function getversion()
    {
        $param = input('param.');
        $model = new VersionModel;
        try{
            if(!empty($param['type'])){
                $type = $param['type'];
                $system = 1;
            }else{
                $type = 2;
                $system = $param['system'];
            }
            $version = $model->findOne(['system'=>$system,'status'=>1,'type'=>$type]);
        } catch (\Exception $e) {
            systembug($e->getMessage(),2,$this->url);
            return admin_json(-1, '获取失败' . $e->getMessage());
        }
        return admin_json(1, '获取成功',$version);
    }
}